package ru.cod.rs.object;

import ru.cod.rs.enums.Actions;
import ru.cod.rs.object.actions.MoveActions;
import android.graphics.Bitmap;

public class MoveObject extends LiveObject implements MoveActions {

	public MoveObject(Bitmap b) {
		super(b);
	}
	
	public MoveObject(Bitmap b, int abc,int ord) {
		super(b,abc,ord);
	}

	protected int speed;
	protected int destination = -1;
	

	@Override
	public void update() {
			if(destination==-1) {
				action=Actions.Right;
			} else {
				if (Math.abs(destination - x) >= speed) {
					if (x < destination) {
						x += speed;
						action = Actions.Right;
					} else if (x > destination) {
						x -= speed;
						action = Actions.Left;
					}
					super.update();
				}
			}
	}

	// /////////////////////////////////
	/**
	 * @return the speed
	 */
	public double getSpeed() {
		return speed;
	}

	/**
	 * @param speed
	 *            the speed to set
	 */
	public void setSpeed(int speed) {
		this.speed = speed;
	}

	/**
	 * @return the destination
	 */
	public double getDestination() {
		return destination;
	}

	/**
	 * @param destination
	 *            the destination to set
	 */
	public void setDestination(int destination) {
		this.destination = destination;
	}

}
